package controllers;

import models.ObjectLevelItem;
import models.Reservation;
import models.User;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: TOSHIBA
 * Date: 15/03/12
 * Time: 00:49
 * To change this template use File | Settings | File Templates.
 */
public class Reservations extends CRUD{


    public static void reserveObjectLevelItem(Long id) {
        ObjectLevelItem item = ObjectLevelItem.findById(id);
        User reservedBy = User.findById(params.get("reservedBy",Long.class));
        User reservedTo = User.findById(params.get("reservedTo",Long.class));
        Reservation reservation;
        Date date = new Date();
        reservation = new Reservation(item,reservedBy,reservedTo,params.get("comment"),date,date,date,params.get("price",Double.class));
        reservation.save();
        render(reservation);
    }

}
